using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;

public class TestObj : MonoBehaviour
{
    public GameObject obj;
    public Animator animator;
    public GameObject idle;
    public GameObject cut;
    public float down_speed;
    public int score;
    public bool down;
    bool destroy;
    private void Awake()
    {
        
    }
    public void OnPointDown2()
    {

            Debug.Log(obj.name);
            animator.speed = 0;
            foreach (MeshRenderer meshRenderer in idle.GetComponentsInChildren<MeshRenderer>())
            {
                meshRenderer.enabled = false;
            }
            gameObject.GetComponent<BoxCollider>().enabled = false;
            cut.SetActive(true);
    }
    public void OnPointDown()
    {
        if (!destroy)
        {
            destroy = true;
            Util.PlayCut();
            Util.AddScore(score);
            Debug.Log(obj.name);
            animator.speed = 0;
            foreach (MeshRenderer meshRenderer in idle.GetComponentsInChildren<MeshRenderer>())
            {
                meshRenderer.enabled = false;
            }
            gameObject.GetComponent<BoxCollider>().enabled = false;
            cut.SetActive(true);
        }
    }
    public void UseDown()
    {
        down = true;
        down_speed = Random.Range(3, 7);
    }
    private void Update()
    {
        if (down)
        {
            if (obj.transform.position.y >= -15)
            {
                Vector3 off  = new Vector3(0, -down_speed * Time.deltaTime, 0);
                obj.transform.position+= off;
            }
            else
            {
                Destroy(obj);
            }
        }
    }
}
